package com.yanfan.information;

import com.alibaba.fastjson2.JSONObject;
import com.yanfan.common.core.domain.AjaxResult;
import com.yanfan.common.utils.Md5Utils;
import com.yanfan.ibms.common.utils.HttpUtils2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
@RequestMapping("/information")
public class ApiInformationController {

    @GetMapping("/getUrl")
    public AjaxResult getTicket() {
        String md5 = Md5Utils.md5("admin12345");
        HashMap<String, Object> map = new HashMap<>();
        map.put("user","root");
        map.put("pwd",md5);
        map.put("action","getticket");
        JSONObject jsonObject = HttpUtils2
                .sendSSLGet("https://192.168.254.8:8443/dmb/out/sso.jsp",
                        "user=root&pwd="+ md5 +"&action=getticket");
        System.out.println(jsonObject);
        String ticket = jsonObject.get("ticket").toString();
        //System.out.println("http://192.168.254.8:8080/dmb/j_acegi_security_check?ticket=" + ticket);
        return AjaxResult
                .success("操作成功",
              "http://192.168.254.8:8080/dmb/j_acegi_security_check?ticket=" + ticket);
    }
}
